<?php
// Test of the limits of the Corner construct
class UTCorner extends UnitTestCase {
    function testConstruct() {
        try {
            $myCorner = new corner(0);
            $this->pass('CORNER type OK');
        }
        catch (Exception $e) {$this->fail();}

        try {
            $myCorner = new corner(corner::MAX_CORNER + 1);
            $this->fail('CORNER TYPE KO 1');
        }
        catch (Exception $e) {$this->pass();}

        try {
            $myCorner = new corner(-1);
            $this->fail('CORNER TYPE KO 2');
        }
        catch (Exception $e) {$this->pass();}

        try {
            $myCorner = new corner("stupid param");
            $this->fail('CORNER TYPE KO 3');
        }
        catch (Exception $e) {$this->pass();}

        try {
            $myCorner = new corner(0, 0);
            $this->pass('CORNER ORIENTATION OK 1');
        }
        catch (Exception $e) {$this->fail();}

        try {
            $myCorner = new corner(0, 1);
            $this->pass('CORNER ORIENTATION OK 2');
        }
        catch (Exception $e) {$this->fail();}

        try {
            $myCorner = new corner(0, 2);
            $this->pass('CORNER ORIENTATION OK 3');
        }
        catch (Exception $e) {$this->fail();}

        try {
            $myCorner = new corner(0, -1);
            $this->fail('CORNER ORIENTATION KO 1');
        }
        catch (Exception $e) {$this->pass();}

        try {
            $myCorner = new corner(0, 3);
            $this->fail('CORNER ORIENTATION KO 2');
        }
        catch (Exception $e) {$this->pass();}
    }
    function testTurnCW() {
        $myCorner = new corner(0, 0);
        $myCorner->turnCW();
        $this->assertTrue($myCorner->getOrientation() === 1);
        $myCorner->turnCW();
        $this->assertTrue($myCorner->getOrientation() === 2);
        $myCorner->turnCW();
        $this->assertTrue($myCorner->getOrientation() === 0);
    }
    function testTurnCCW() {
        $myCorner = new corner(0, 0);
        $myCorner->turnCCW();
        $this->assertTrue($myCorner->getOrientation() === 2);
        $myCorner->turnCCW();
        $this->assertTrue($myCorner->getOrientation() === 1);
        $myCorner->turnCCW();
        $this->assertTrue($myCorner->getOrientation() === 0);
    }
}
?>
